#ifndef UNITITEMS_H
#define UNITITEMS_H

#include <QDialog>
#include "itemfactorymodel.h"
#include "unititemmodel.h"

namespace Ui {
class UnitItems;
}

class UnitItems : public QDialog
{
    Q_OBJECT
    
public:
    explicit UnitItems(const DualCollection<GameItem> *items, const DualCollection<GameCategory> *categories, QWidget *parent = 0);
    ~UnitItems();

    void setSourceUnit(RosterUnit *unit);

public slots:
    void armyFileChanged();

protected:
    void changeEvent(QEvent *e);
    
private slots:
    void itemFactoryView_selectionChanged(const QModelIndex& current, const QModelIndex& previous);
    void unitItemView_selectionChanged(const QModelIndex& current, const QModelIndex& previous);

    void on_itemFactoryView_doubleClicked(const QModelIndex &index);

    void on_amountButton_clicked();
    void on_subtractButton_clicked();
    void on_deleteButton_clicked();

private:
    Ui::UnitItems *ui;
    ItemFactoryModel factoryModel;
    UnitItemModel unitItemModel;
    RosterUnit *currentUnit;

    const DualCollection<GameItem> *_items;
};

#endif // UNITITEMS_H
